package com.oocl.dataproduce;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;


public class DataProducer {
	
    public  void dataProduce(){
    	OutputStream out = null;
		try {
			out = new  FileOutputStream("data.xml");
			out.write("<books>\n".getBytes());
    	 for(int i=1;i<=10000;i++){
    		 double temp = (int)(Math.random()*50)+0.50;
				String s = "<book>\n";
				      s += "<id>"+i+"</id>\n";
				      s += "<name>book"+i+"</name>\n";
				      s += "<pubDate>2008-08-08</pubDate>\n";
				      s += "<author>AA"+i+"</author>\n";
				      s += "<price>"+temp+"</price>\n";
				      s += "<newBook>true</newBook>\n";
				      s += "<publisher>beijing</publisher>\n";
				      s += "</book>\n";
			out.write(s.getBytes());   
				 
			}
    	 out.write("</books>\n".getBytes());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
    }
}
